//
//  API.h
//  KiklinkApp
//
//  Created by LF on 14-9-28.
//  Copyright (c) 2014年 Kiklink. All rights reserved.
//

#import <Foundation/Foundation.h>
#import "DataType.h"
#import "StatusCode.h"
#import "AccountManager.h"
#import "SNSManager.h"

@interface API : NSObject

//以下各方法中，callback不可为nil

//登陆开练网
//内部用，外部应使用AccountManager中的
+ (void)loginKiklinkWithUsername:(NSString*)username Password:(NSString*)password Callback:(Callback) callback;

//从开练网退出登录
//此方法不会失败
+ (void)logoutKiklinkWithCallback:(Callback) callback;

//发送验证码
//服务器返回错误码：?
+ (void)sendVerificationCodeToPhoneNumber:(NSString *)phoneNumber callback:(Callback)callback;

//注册开练账号
//服务器端行为：
//出错时返回的服务器端错误码均为-1
//返回的word可为“手机号已经被注册”、“手机验证码错误”（仅验证码为空时）、"手机号不能为空"、“手机号格式错误”，多种提示会以空格隔开，不易直接判断
//不检查用户名（应为3~20字符），不检查验证码是否正确
//应自行检查手机号、用户名的合法性、两次密码的一致性，仅利用返回验证手机号是否可用
+ (void)registKiklinkWithPhoneNumber:(NSString*)phoneNumber verificationCode:(NSString*)verificationCode displayName:(NSString*)username password:(NSString*)password Callback:(Callback) callback;

//重设密码
//错误同注册开练账号
+ (void)resetPasswordWithPhoneNumber:(NSString*)phoneNumber verificationCode:(NSString*)verificationCode password:(NSString*)password Callback:(Callback) callback;

//以第三方账号登陆开练网，需先在第三方平台登录成功拿到token
//thirdType:qq或weibo
+ (void)thirdPartyLoginKiklinkWithType:(NSString*)thirdType id:(NSString*)userId token:(NSString*)token displayName:(NSString*)displayName sex:(NSNumber*)sex Callback:(Callback) callback;

//以第三方账号登陆后，绑定手机号至此账号
//服务器返回错误码：?
+ (void)bindPhoneNumber:(NSString *)phoneNumber callback:(Callback)callback;

//首页活动图片
//content: NSMutableArray->HomeImage
+ (void)homeActivityImageWithCallback: (Callback)callback;

//首页特惠推荐
//content: ProductPage->result: Product
+ (void)homeRecommendPageWithPageNumber:(NSNumber *)pageNumber Callback:(Callback)callback;

//查看课程详情
//content: Product
+ (void)productDetailWithId:(NSNumber *)Id Callback:(Callback)callback;

//课程搜索
//SortStyle[人气buyedCount desc/价格price]
//字符串参数为空时应使用@""，不可为nil
//content: ProductPage->result: Product
+ (void)courseSearchWithKeyword:(NSString *)keyword distance:(NSNumber *)distance tags:(NSString *)tags category:(NSNumber*)category sortStyle:(NSString *)sortStyle pageNumber:(NSNumber *)pageNumber Callback:(Callback)callback;

//获取指定课程的多个教练
//content: NSMutableArray->Coach
+(void)coachWithProductId:(NSNumber*)productId Callback:(Callback)callback;

//获取指定课程的评论
//content: CommentPage->result: Comment
+(void)commentPageWithProductId:(NSNumber*)productId PageNumber:(NSNumber*)pageNumber Callback:(Callback)callback;

//获取待评价的课程
//content: OrderItemPage->OrderItem
+(void)uncommentedOrderItemPageWithPageNumber:(NSNumber*)pageNumber Callback:(Callback)callback;

//增加评论
+(void)addCommentWithProductId:(NSNumber*)productId comment:(NSString*)comment pointDescriptionMath:(NSNumber*)pointDescriptionMath pointProfessional:(NSNumber*) pointProfessional pointServiceAttitude:(NSNumber*)pointServiceAttitude pointAppointmentSuccessful:(NSNumber*)pointAppointmentSuccessful callback:(Callback)callback;

//获取指定课程的购买记录
//content: SellRecordPage->result: SellRecord
+(void)sellRecordPageWithProductId:(NSNumber*)productId PageNumber:(NSNumber*)pageNumber Callback:(Callback)callback;

//获取收藏的课程
//content: FavoriteItemPage->result: FavoriteItem
+(void)favouriteProductPageWithPageNumber:(NSNumber*)pageNumber Callback:(Callback)callback;

//获取单个收藏的课程
//content: FavoriteItemPage->result: FavoriteItem
+(void)favouriteProductPageWithProductId:(NSNumber*)itemId Callback:(Callback)callback;

//添加收藏的课程
//content: 无
//服务器返回错误码 -2：请勿重复收藏
+(void)addFavouriteProductWithProductId:(NSNumber*)itemId Callback:(Callback)callback;

//删除收藏的项目，不区分商品或店铺
//content: 无
//参数FavouriteId为FavouriteItem中的id项，此id为个人收藏中的项目序号，与全局的ProductId/ShopId不同
//服务器返回错误码 -2：收藏不存在，可能已被删除过
+(void)removeFavouriteItemWithFavouriteId:(NSNumber*)itemId Callback:(Callback)callback;

//获取店铺详情
//content: Shop
+(void)shopDetailWithShopId:(NSNumber*)shopId Callback:(Callback)callback;

//获取我的订单(全部订单）
//content: OrderPage->result: Order
+(void)myOrderPageWithPageNumber:(NSNumber*)pageNumber Callback:(Callback)callback;

//获取已支付订单
//content: OrderPage->result: Order
+(void)payedOrderPageWithPageNumber:(NSNumber*)pageNumber Callback:(Callback)callback;

//获取未支付订单
//content: OrderPage->result: Order
+(void)unpayedOrderPageWithPageNumber:(NSNumber*)pageNumber Callback:(Callback)callback;

//获取单页订单详情（API内部用）
//订单中的具体课程可有多项，是分页的，本方法仅返回其中一页。
//content: NSDictionary->order: Order, orderItemPage: OrderItemPage
+(void)orderDetailWithOrderId:(NSNumber*)orderId PageNumber:(NSNumber*)pageNumber Callback:(Callback)callback;

//获取订单全部详情（外部用）
//返回订单中包含的全部课程。
//content: NSDictionary->order: Order, orderItemPage: OrderItemPage
+(void)orderDetailWithOrderId:(NSNumber*)orderId Callback:(Callback)callback;

//提交订单
+(void)addOrderWithProductId:(NSNumber*)productId count:(NSNumber*)count callback:(Callback)callback;

//获取用户消息
//content:MessagePage->result: Message
+(void)userMessageWithPageNumber:(NSNumber*)pageNumber callback:(Callback)callback;

//获取系统消息
//content:MessagePage->result: Message
+(void)systemMessageWithPageNumber:(NSNumber*)pageNumber callback:(Callback)callback;

//获取已删除的消息
//content:MessagePage->result: Message
+(void)deletedMessageWithPageNumber:(NSNumber*)pageNumber callback:(Callback)callback;

//删除消息
+(void)deleteMessageWithMessageId:(NSNumber*)messageId callback:(Callback)callback;

+(void)restoreMessageWithMessageId:(NSNumber*)messageId callback:(Callback)callback;

+(void)replyMessageWithMessageId:(NSNumber*)messageId content:(NSString*)content callback:(Callback)callback;
@end
